﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;

namespace WebSite.Admin.SystemSet
{
    public partial class MoneyCardCreate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region 生成卡号
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string num = txtNumber.Text.Trim();
            if (string.IsNullOrEmpty(num))
            {
                Tools.Alert("请输入个数");
                return;
            }
            int money =Convert.ToInt32( ddlMoney.SelectedValue);
            int cardnum = Convert.ToInt32(num);
            for (int i = 0; i < cardnum; i++)
            {
                string randN = Tools.GetRndNum(6);
                string no = randN.Substring(4, 2) + DateTime.Now.ToString("mm") + DateTime.Now.ToString("yyyy") + randN.Substring(0, 1) + DateTime.Now.ToString("dd") + randN.Substring(1, 1) + DateTime.Now.ToString("MM") + randN.Substring(2, 1) + DateTime.Now.ToString("HH") + DateTime.Now.ToString("ss") + randN.Substring(3, 1);

                MoneyCard mcinfo = new MoneyCard();
                MoneyCardHelper mchelper = new MoneyCardHelper();
                mcinfo.MoneyCardNo = no;
                mcinfo.Flag = 0;
                mcinfo.Money = money;
                mcinfo.Status = 0;
                mchelper.AddMoneyCard(mcinfo);
            }

            Tools.AlertAndRedirect("生成成功", "MoneyCardList.aspx");
            return;
        }
        #endregion
    }
}